package router

import (
	"github.com/gin-gonic/gin"
	"guliedu/controller"
	"guliedu/middleware"
	"guliedu/utils"
)

func init() {
	gin.SetMode(utils.AppMode)
	r := gin.Default()
	r.Use(middleware.Cors())

	adminAuthRouter := r.Group("/eduservice", middleware.JwtToken())

	// 教师
	adminAuthRouter.POST("/teacher/pageTeacherCondition/:page/:pageSize", controller.SelectPageTeacher)
	adminAuthRouter.DELETE("/teacher/:id", controller.Delete)
	adminAuthRouter.POST("/teacher/addTeacher", controller.InsertOrSave)
	adminAuthRouter.GET("/teacher/getTeacher/:id", controller.SelectTeacher)
	adminAuthRouter.PUT("/teacher/updateTeacher/:id", controller.InsertOrSave)
	adminAuthRouter.POST("/teacher/uploadProfile", controller.UploadProfile)
	adminAuthRouter.GET("/teacher/findAll", controller.SelectAllTeacher)

	// 分类
	adminAuthRouter.GET("/subject/addOne/:title", controller.InsertOneSubject)
	adminAuthRouter.GET("/subject/oneSubjectAll", controller.SelectOneSubject)
	adminAuthRouter.GET("/subject/addTwo/:id/:title", controller.InsertTwoSubject)
	adminAuthRouter.GET("/subject/subjectAll", controller.SelectAllSubject)
	adminAuthRouter.GET("/subject/findAllSubject", controller.FindAllSubject)

	// 课程
	adminAuthRouter.POST("/course/addCourseInfo", controller.AddCourse)
	adminAuthRouter.POST("/course/cover", controller.UploadCourseCover)
	adminAuthRouter.GET("/course/getCourseInfo/:id", controller.GetCourseInfo)
	adminAuthRouter.PUT("/course/updateCourseInfo", controller.UpdateCourseInfo)
	r.DELETE("/courseId/video/:id", controller.DeleteVideo)
	adminAuthRouter.GET("/course/getPublishCourseInfo/:id", controller.GetPublishCourse)
	adminAuthRouter.POST("/course/publishCourse/:id", controller.PublishCourse)
	adminAuthRouter.GET("/course", controller.SelectAllCourse)
	adminAuthRouter.DELETE("/course/:id", controller.DeleteCourse)

	// 章节
	adminAuthRouter.POST("/chapter/addChapter", controller.AddChapter)
	adminAuthRouter.GET("/chapter/getChapterVideo/:courseID", controller.GetChapterVideo)
	adminAuthRouter.GET("/chapter/getChapterInfo/:id", controller.GetChapterInfo)
	adminAuthRouter.PUT("/chapter/updateChapter", controller.UpdateChapter)
	adminAuthRouter.DELETE("/chapter/:id", controller.DeleteChapter)

	// 每日统计
	r.GET("/statistics/showData/:type/:begin/:end", controller.SelectDaily)

	// 视频
	adminAuthRouter.POST("/video/uploadQiNiuYunVideo", controller.UploadQiNiuYunVideo)
	adminAuthRouter.POST("/video/addVideo", controller.AddVideo)
	r.GET("/courseId/video/:id", controller.SelectVideo)
	r.PUT("/courseId/video/updateVideo", controller.UpdateVideo)

	// 轮播图
	adminAuthRouter.POST("/banner/uploadBanner", controller.UploadBanner)
	adminAuthRouter.POST("/banner/addBanner", controller.AddBanner)
	adminAuthRouter.GET("/banner/pageBannerCondition/:page/:pageSize", controller.GetBannerListPage)
	adminAuthRouter.GET("/banner/getBanner/:id", controller.GetBanner)
	adminAuthRouter.PUT("/banner/updateBanner/:id", controller.UpdateBanner)
	adminAuthRouter.DELETE("/banner/:id", controller.DeleteBanner)

	// 首页
	r.GET("/edu/indexFront/index", controller.GetIndexData)
	r.GET("/cms/bannerFront/getAllBanner", controller.GetAllBanner)

	// 前台名师
	r.GET("/edu/teacherFront/getTeacherInfoList/:page/:pageSize", controller.GetTeacherInfoList)
	r.GET("/edu/teacherFront/getTeacherFrontInfo/:id", controller.GetTeacherInfo)

	// 前台课程
	r.POST("/edu/courseFront/getFrontCourse/:page/:pageSize", controller.GetFrontCourseList)
	r.GET("/edu/courseFront/getFrontCourseInfo/:id", controller.GetFrontCourseInfo)

	// 评论
	adminAuthRouter.POST("/comment/auth/save", controller.AddComment)
	r.GET("/eduservice/comment/:page/:pageSize", controller.SelectComment)
	adminAuthRouter.POST("/comment/pageCommentCondition/:page/:pageSize", controller.SelectAll)
	adminAuthRouter.DELETE("/comment/:id", controller.DeleteComment)

	// 会员
	r.POST("/ucenter/member/register", controller.RegisterMember)
	r.GET("/msm/send/:email", controller.MemberSendEmail)
	r.POST("/ucenter/member/login", controller.LoginMember)
	r.GET("/ucenter/member/getMemberInfo", controller.GetMemberInfo)

	// 登入
	r.POST("/eduservice/user/login", controller.Login)
	r.GET("/eduservice/user/info", controller.Info)

	r.Run(utils.HttpPort)
}
